{{- $params := .Params | merge .Site.Params.page -}}

<article class="single summary" itemscope itemtype="http://schema.org/Article">
  {{- /* Featured image */ -}}
  {{- $image := $params.featuredimagepreview | default $params.featuredimage -}}
  {{- with .Resources.GetMatch "featured-image" -}}
    {{- $image = .RelPermalink -}}
  {{- end -}}
  {{- with .Resources.GetMatch "featured-image-preview" -}}
    {{- $image = .RelPermalink -}}
  {{- end -}}
  {{- with $image -}}
    <div class="featured-image-preview">
      <a href="{{ $.RelPermalink }}" aria-label="{{ $.Title }}">
        {{- dict "Src" . "Title" $.Description "Alt" $.Title "Resources" $.Resources | partial "plugin/image.html" -}}
      </a>
    </div>
  {{- end -}}

  {{- /* Title */ -}}
  <h2 class="single-title" itemprop="name headline">
    {{- with $params.weight -}}
      {{- $icon := dict "Class" "fa-solid fa-thumbtack fa-fw" -}}
      <span title="{{ T "single.pin" }}" class="icon-pin">{{- $icon | partial "plugin/icon.html" -}}</span>
    {{- end -}}
    {{- $repost := $params.repost | default dict -}}
    {{- with $repost -}}
      {{- if eq .Enable true -}}
        {{- $icon := dict "Class" "fa-solid fa-share fa-fw" -}}
        {{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "single.repost") .Url ) (T "single.repost") -}}
        <span title="{{ $title }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
      {{- end -}}
    {{- end -}}
    <a href="{{ .RelPermalink }}">{{ title .Title }}</a>
  </h2>

  {{- /* Meta */ -}}
  <div class="post-meta">
    {{- partial "single/post-author.html" . -}}

    {{- with .PublishDate | dateFormat (.Site.Params.dateFormat | default "2006-01-02") -}}
      &nbsp;<span class="post-publish" title='{{ "2006-01-02 15:04:05" | $.PublishDate.Format }}'>
        {{- printf `<time datetime="%v">%v</time>` . . | dict "Date" | T "single.publishedOnDate" | safeHTML -}}
      </span>
    {{- end -}}

    {{- partial "single/post-included-in.html" . -}}
  </div>

  {{- /* Summary content */ -}}
  <div class="content">
    {{- with .Summary -}}
      {{- dict "Content" . "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
    {{- else -}}
      {{- .Description | safeHTML -}}
    {{- end -}}
  </div>

  {{- /* Footer */ -}}
  <div class="post-footer">
    <a href="{{ .RelPermalink }}">{{ T "single.readMore" }}</a>
    {{- $tagTerms := .GetTerms "tags" -}}
    {{- if $tagTerms -}}
      <div class="post-tags">
        {{- dict "Class" "fa-solid fa-tags fa-fw me-1" | partial "plugin/icon.html" -}}
        {{- range $tagTerms -}}
          <a href='{{ partial "function/escapeurl.html" .RelPermalink }}' class="post-tag">{{ .LinkTitle }}</a>
        {{- end -}}
      </div>
    {{- end -}}
  </div>
</article>
